﻿using System;
using System.Collections.Generic;

namespace KLS.PPDS.ApplicationService.Manager
{
    public class Months
    {
        public int Month { get; set; }
        public string Name { get; set; }
    }

    public sealed class YearMonthManager
    {
       // public static readonly IList<Months> MonthList = new List<Months>(new Months(){Month = 1,} );

       // private static  IList<Months> Months { get; set; }
   //     private static IList<int> Years { get; set; }
        

        public static IList<int> GetYear( int companyId)
        {
      
            var years = new List<int>();
            var x = DateTime.Now.Year;

            for (int i = x; i <= DateTime.Now.Year+5; i++)
            {
                years.Add(i);
            }
      
            var years2 = PublicationManager.GetPublicationDistinctYear(companyId);

            if (years2 != null && years2.Count > 0) 
            {
                foreach (var year in years2) 
                {
                    if (!years.Contains(year)) 
                    {
                        years.Add(year);
                    }
                }
            }



            return years;
        }

        public static IList<Months> GetMonths ()
        {
             var   monthsList = new List<Months>();

                for (int i = 1; i < 13; i++)
                {
                    monthsList.Add(new Months() { Month = i, Name = GetMonthName(i, true) });
                }

                return monthsList;
        }

        public static string GetShortMonthName(int month)
        {
            return GetMonthName(month, true);
        }

        /// <summary>
        /// Converts the given month int to month name
        /// </summary>
        /// <param name="month">month in</param>
        /// <param name="abbrev">return abbreviated or not</param>
        /// <returns>Short or long month name</returns>
        private static string GetMonthName(int month, bool abbrev)
        {
            DateTime date = new DateTime(1900, month, 1);
            if (abbrev) 
            {
                return date.ToString("MMM");
            } 
            return date.ToString("MMMM");
        }
    }


   
}
